#include "guiterm.hpp"
#ifndef PROGRAMVIEW_HPP
#define PROGRAMVIEW_HPP

/// The view of a job (running or finished) run from the shell. Includes
/// the history entry it was run with, a dropdown menu for actions controlling
/// the job, and a terminal displaying its output.
class JobView
	:public ViewSegment
{
	Q_OBJECT
public:
	JobView(RemoteJob *owner, bool showHeader, string cmd);
	~JobView();
	
	RemoteJob *getJob() const;
	
	void jobFinished(int result);
	
	int getHeaderHeight();
	bool isFocused() const;
	void giveFocus();
	
	int numSegments() const;
	ViewSegment *getSegment(int index);
	void addSegment(ViewSegment *segment);
	
	//QSize sizeHint() const;
	int heightForWidth(int width) const;
	
protected slots:
	void openContextMenu();
	void moveToNewWindow();
	
protected:
	void keyPressEvent(QKeyEvent *event);
	void mousePressEvent(QMouseEvent *event);
	
	RemoteJob *owner;
	TerminalWindow *window;
	
	QHBoxLayout *headerLayout;
	QVBoxLayout *layout;
	
	QLabel *headerLabel;
	LinkWidget *menuLink;
	
	vector<ViewSegment*> segments;
};

#endif
